<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
	<base href="${pageContext.request.contextPath}/">
	<title>Title</title>
	<link rel="stylesheet" href="assets/layui/css/layui.css">
	<link rel="stylesheet" href="assets/css/base.css">
	<style>

	</style>
</head>
<body>

<div class="page fx-col">
	<input type="hidden" id="id" value="${subject.id}"/>
	<label >学科名称： <input type="text" id="name" class="layui-input" value="${subject.name}"></label>
	<button class="layui-btn mt-15" id="save_btn">保存</button>
</div>


</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="assets/layui/layui.all.js"></script>

<script>
	$(function () {
		$(document).on("click", "#save_btn", function () {
			let name = $("#name").val();
			let id = $("#id").val();
			$.ajax({
				url: "subject/save",
				type: "post",
				data: {name,id},
				dataType: "json",
				success(res) {
					if (res.success) {
						layer.msg('保存成功', {icon: 6}, function () {
							window.parent.search();
						});

					} else {
						layer.msg(res.msg, {icon: 2});
					}
				}

			})


		})





	})
</script>
</html>
